package com.facebook.listener;

import android.app.Activity;
import android.content.Intent;
import android.widget.Toast;

import com.facebook.android.FacebookError;
import com.imoblife.brainwavestus.share.BaseRequestListener;
import com.imoblife.brainwavestus.share.FriendsList;

/*
 * callback after friends are fetched via me/friends or fql query.
 */
public class FriendsRequestListener extends BaseRequestListener {

	private Activity mActivity;
	private String graph_or_fql;

	public FriendsRequestListener(){}
	
	public FriendsRequestListener(Activity activity,String graphOrFql) {
		this.mActivity = activity;
		this.graph_or_fql = graphOrFql;
	}
	public void onComplete(final String response, final Object state) {
		Intent myIntent = new Intent(mActivity.getApplicationContext(),
				FriendsList.class);
		myIntent.putExtra("API_RESPONSE", response);
		myIntent.putExtra("METHOD", graph_or_fql);
		mActivity.startActivity(myIntent);
	}

	public void onFacebookError(FacebookError error) {
		Toast.makeText(mActivity.getApplicationContext(),
				"Facebook Error: " + error.getMessage(), Toast.LENGTH_SHORT)
				.show();
	}
}
